import requests
import time
from get_anti_content import get_anti_content, get_proxy_no, get_access_token

cookies = {
    '_bee': 'j4sFD92EXhkNW1g6CBXTtVFhzZfFD0yO',
    '_f77': 'eff1e851-acec-4086-a75c-8103cb0a5907',
    '_a42': 'be292171-864e-45ac-a08b-68971f365e12',
    'rckk': 'j4sFD92EXhkNW1g6CBXTtVFhzZfFD0yO',
    'ru1k': 'eff1e851-acec-4086-a75c-8103cb0a5907',
    'ru2k': 'be292171-864e-45ac-a08b-68971f365e12',
    'JSESSIONID': '1C3FEBF2259448375A78D6BC542811C3',
    'api_uid': 'CiYY3mY83oxmEABoQxZcAg==',
}

headers = {
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7',
    'accesstoken': 'FFI246EXOUGFUKX25C3RGY7SEEHO3GMR6FIK7PVXPSBHMFBWRWJA1200774',
    'anti-content': '0asAfaid0yGoy99qlhUK1lphXBVCUFAQOOk4Oez1F_Fk1vfFaGDK88jfANy_zy_TDHP5C3jm6nysCT7n8gTag82a7NCR9OHovMcVclbcRg_T209ymhKP8C_Vzho95rsBAIgI2AtpAks0hBoWoWAoDmSKBgr06-ofXcuXfTbNvSin1Ddet3NLGXA0bpMyrcp3A6Y3upkMBfS11EIc1M1tvvs-1ZUu4v5-S1tX1eAB_3DeJqNabFf89dwjjT0T1U5Bat4xuKb-hd0cszs4KfTsSbndNJ4xnT7Ef3qZ-ObhYa4ju2_U-D4e6-OcI-a44MKEs54qT3DCPzjqyoHt3ScSTMCIMQCRl_hXUak86dSHI1zdE56-OsXoj8wJ-37QdGwkEW58HLCvHGNEKtYGD3832UvjRKzEbNyBOpns88UylQjAI2kka7aw5FilWJQQExyCCEFT7Cqzx4jIDFjz-lwc3KWEuOwheUJqlvceRJ2ksTLWMCpQH27PhgGtwRfN2SvyHNJ',
    'origin': 'https://ktt.pinduoduo.com',
    'priority': 'u=1, i',
    'referer': 'https://ktt.pinduoduo.com/',
    'sec-ch-ua': '"Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36',
    # 'cookie': '_bee=j4sFD92EXhkNW1g6CBXTtVFhzZfFD0yO; _f77=eff1e851-acec-4086-a75c-8103cb0a5907; _a42=be292171-864e-45ac-a08b-68971f365e12; rckk=j4sFD92EXhkNW1g6CBXTtVFhzZfFD0yO; ru1k=eff1e851-acec-4086-a75c-8103cb0a5907; ru2k=be292171-864e-45ac-a08b-68971f365e12; JSESSIONID=1C3FEBF2259448375A78D6BC542811C3; api_uid=CiYY3mY83oxmEABoQxZcAg==',
}

params = {
    'page_number': '1',
    'page_size': '10',
    'keyword': '',
    'category_id': '',
    'proxy_no': 'o0OvZlbhjpYoUqb0sjXzxA==',
    'sign': '75EF139E23C7D821B6A2D74BA4C344FA',
    'signVersion': 'sv1',
    'timestamp': int(time.time() * 1000),
}

params = {
    'proxy_no': get_proxy_no(),
}

headers['accesstoken'] = get_access_token()
headers['anti-content'] = get_anti_content()

print('GET', 'https://api.pinduoduo.com/api/ktt_group/goods_library/material/query_page')
response = requests.get(
    'https://api.pinduoduo.com/api/ktt_group/goods_library/material/query_page',
    params=params,
    cookies=cookies,
    headers=headers,
)

print(response.text)